from itsdangerous import TimedJSONWebSignatureSerializer as JiaMiClass


def token_secret():
    #  1. 实例化
    jiami_obj = JiaMiClass(secret_key='miyao')

    #  2. 加密--载荷 跟你业务相关
    data = {'name': "laowang"}

    # ==>  bytes.decode() == >ste
    secrect_str = jiami_obj.dumps(data).decode()
    print(secrect_str)

    #  3. 解密
    result = jiami_obj.loads(secrect_str)
    print(result)
    print(type(result))

if __name__ == '__main__':
    # print(token_secret())


    import base64
    result = '12345'.encode()
    #  加密
    b64_data = base64.b64encode(result)
    print(b64_data)
    # 解码 解密
    origin_data = base64.b64decode(b64_data)
    print(origin_data)
